package cn.getech.data.development.model.ranger;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.google.common.collect.Lists;
import lombok.*;

import java.util.List;
import java.util.Map;

/**
 * @author hujz
 */
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class RangerPolicy {
    Map<String, RangerPolicyResource> resources;
    List<RangerPolicyItem> policyItems = Lists.newArrayList();
    List<RangerPolicyItem> denyPolicyItems = Lists.newArrayList();
    List<RangerPolicyItem> allowExceptions = Lists.newArrayList();
    List<RangerPolicyItem> denyExceptions = Lists.newArrayList();
    List<RangerMaskPolicyItem> dataMaskPolicyItems = Lists.newArrayList();
    List<RangerRowFilterPolicyItem> rowFilterPolicyItems = Lists.newArrayList();
    private Integer id;
    private String guid;
    private boolean isEnabled;
    private int version;
    private String service;
    private String name;
    /***
     * 策略类型  0：access 库表字段权限策略  1：masking 字段加密权限策略  2：row level filter 行过滤策略
     */
    private int policyType;
    private String description;
    private boolean isAuditEnabled;

    @Override
    public String toString() {
        return "Policy{" +
                "id=" + id +
                ", guid='" + guid + '\'' +
                ", isEnabled=" + isEnabled +
                ", version=" + version +
                ", service='" + service + '\'' +
                ", name='" + name + '\'' +
                ", policyType=" + policyType +
                ", description='" + description + '\'' +
                ", isAuditEnabled=" + isAuditEnabled +
                ", ResourcesObject=" + resources +
                ", policyItems=" + policyItems +
                ", denyPolicyItems=" + denyPolicyItems +
                ", allowExceptions=" + allowExceptions +
                ", denyExceptions=" + denyExceptions +
                ", dataMaskPolicyItems=" + dataMaskPolicyItems +
                ", rowFilterPolicyItems=" + rowFilterPolicyItems +
                '}';
    }
}
